<?php
defined('_JEXEC') or die( 'Restricted access' );

jimport( 'joomla.application.component.view');

class igcategoriesViewigcategories extends JView
{
	function display($tpl = null)
	{
		global $mainframe, $option;
		
		$configArray =& JComponentHelper::getParams('com_igallery');
		$moderate = $configArray->get('moderate_cat', 0);
		
		JToolBarHelper::title( JText::_( 'IGNITE GALLERY' ), 'generic.png' );
		JToolBarHelper::custom('add_category_redirect', 'new', '', JText::_( 'NEW CATEGORY' ), false);
		JToolBarHelper::custom('copy', 'copy', '', JText::_( 'COPY CATEGORY' ) );
		JToolBarHelper::publish();
		JToolBarHelper::unpublish();
		
		if( !empty($moderate) )
		{
			JToolBarHelper::custom('moderate', 'tick.png', 'tick.png', JText::_( 'APPROVE' ) );
			JToolBarHelper::custom('unmoderate', 'unmoderate.png', 'unmoderate.png', JText::_( 'UNAPPROVE' ) );
		}
		
		JToolBarHelper::deleteList( JText::_( 'CONFIRM DELETE CATEGORY' ) );
		
		$toolBar = & JToolBar::getInstance('toolbar');
		$toolBar->appendButton( 'Popup', 'config', 'Preferences', 'index.php?option=com_igallery&amp;controller=igcategories&amp;view=igconfig', 580, 550 );
        
		$context = 'igcategories';
		$filter_state		= $mainframe->getUserStateFromRequest( $context.'.filter_state',		'filter_state',		'',				'word' );
		$filter_order		= $mainframe->getUserStateFromRequest( $context.'.filter_order',		'filter_order',		'ordering',	'cmd' );
		$filter_order_Dir	= $mainframe->getUserStateFromRequest( $context.'.filter_order_Dir',	'filter_order_Dir',	'',				'word' );
		$search				= $mainframe->getUserStateFromRequest( $context.'.search',			'search',			'',				'string' );
		$search				= JString::strtolower($search);

		$items		= & $this->get( 'Data');
		$total		= & $this->get( 'Total');
		$pagination = & $this->get( 'Pagination' );
		
		$lists = array();
		$lists['state']	= JHTML::_('grid.state',  $filter_state );
		$lists['order_Dir'] = $filter_order_Dir;
		$lists['order'] = $filter_order;
		$lists['search']= $search;
		
		$document =& JFactory::getDocument();
		$document->addStyleSheet(IG_HOST.'components/com_igallery/css/toolbar.css');
		
		$db	=& JFactory::getDBO();
		
		$this->assignRef('moderate',	$moderate);
		$this->assignRef('db',		    $db);
		$this->assignRef('lists',		$lists);
		$this->assignRef('items',		$items);
		$this->assignRef('pagination',	$pagination);

		parent::display($tpl);
	}
}